import sys
import os
import shutil

sys.path.append('/usr/lib64/freecad/lib/')
sys.path.append('/FreeCAD_build/lib/')

from ..step import Step

name = sys.argv[1]
print('name:', name)

path, basename = os.path.split(name)
filename = os.path.splitext(basename)[0]
#doc = Step.openFile('./data/step/box.stp')
stepFile = './data/step/' + name

print ('stepFile:', stepFile)
doc = Step.openFile(stepFile)
#doc = Step.openFile('./data/box_nocolor.step')
doc.visualize()
tuoVisualPath = './data/TuoVisual/' + filename
if not os.path.exists(tuoVisualPath):
    os.makedirs(tuoVisualPath)
tuoVisualName = tuoVisualPath + '/' + filename

doc.exportTuoVisual(tuoVisualName)

sourcePath = tuoVisualPath
objPath = '/tuo-visual/examples/public/data/' + filename
if os.path.exists(objPath):
    print('removePath:', objPath)
    shutil.rmtree(objPath)

shutil.copytree(sourcePath, objPath)


#doc.exportTuoVisual('./data/TuoVisual/0002/0002')
#doc.exportTuoVisual('./data/TuoVisual/box/box')

